<template>
	<view class="wrapper">
		<view class="search_wrapper">
			<view class="search">
				<u-search placeholder="请输入" v-model="keyword" :showAction="false"></u-search>
			</view>
			<uni-data-select v-model="value" :localdata="range" @change="change"></uni-data-select>
		</view>
		<view class="page_wrapper">
			<u-list @scrolltolower="scrolltolower">
				<u-list-item v-for="(item, index) in indexList" :key="index" @click.native="gotoDetails">
					<!-- <u-cell :title="`列表长度-${index + 1}`">
						<u-avatar slot="icon" shape="square" size="35" :src="item.url"
							customStyle="margin: -3px 5px -3px 0"></u-avatar>
					</u-cell> -->
					<view class="content">
						<view class="top">
							<view class="address">
								<u--text :text="item.houseName" size="14" lineHeight="38" align="right"></u--text>
							</view>
							<view class="name">
								<u--text :text="item.tenantName" size="14" lineHeight="38"></u--text>
							</view>
						</view>
						<view class="bottom">
							<u--text :text="item.beginDate+'/'+item.endDate" size="14" lineHeight="38"></u--text>
						</view>
					</view>
				</u-list-item>
			</u-list>
		</view>
	</view>

</template>

<script>
	import {
		getLeaseList,
		getAchievement
	} from '@/api/my/index.js'
	export default {
		data() {
			return {
				keyword: '',
				value: 1,
				range: [{
						value: 0,
						text: "不限"
					},
					{
						value: 1,
						text: "租期中"
					},
					{
						value: 2,
						text: "即将到期"
					},
				],
				indexList: [],
				urls: [
					'https://cdn.uviewui.com/uview/album/1.jpg',
					'https://cdn.uviewui.com/uview/album/2.jpg',
					'https://cdn.uviewui.com/uview/album/3.jpg',
					'https://cdn.uviewui.com/uview/album/4.jpg',
					'https://cdn.uviewui.com/uview/album/5.jpg',
					'https://cdn.uviewui.com/uview/album/6.jpg',
					'https://cdn.uviewui.com/uview/album/7.jpg',
					'https://cdn.uviewui.com/uview/album/8.jpg',
					'https://cdn.uviewui.com/uview/album/9.jpg',
					'https://cdn.uviewui.com/uview/album/10.jpg',
				]
			}
		},

		onLoad() {
			this.loadmore()
		},
		methods: {
			change() {

			},
			scrolltolower() {
				this.loadmore()
			},
			loadmore() {
				let res = getLeaseList().then(res=>{
					this.indexList = res.data.rows
				})
				for (let i = 0; i < 30; i++) {
					this.indexList.push({
						url: this.urls[uni.$u.random(0, this.urls.length - 1)]
					})
				}
			},
			gotoDetails(){
				uni.navigateTo({
					url:'/pages/my/leaseDetails'
				})
			}
		},
	}
</script>

<style scoped lang="scss">
	.wrapper {
		background-color: #eee;
		min-height: 100vh;

		.search_wrapper {
			display: flex;
			padding: 10rpx;
			background-color: #fff;

			.search {
				width: 65%;
			}
		}

		.page_wrapper {
			.content {
				background-color: #fff;
				margin: 20rpx;

				.top {
					display: flex;
					justify-content: space-between;
					border-bottom: 1px solid #eee;

					.address,
					.name {
						padding: 5rpx 10rpx;
					}

				}

				.bottom {
					padding: 5rpx 10rpx;
				}
			}
		}
	}
</style>